﻿using BusinessObjects;
using DataObjects.Interfaces;
using System.Linq;

namespace DataObjects.Entity
{
    public class EntityCustomerDao : ICustomerDao
    {
        public Customer GetCustomer(string customerId)
        {
            using (var context = EntityObjectFactory.CreateContext())
            {
                CustomerEntity entity = context.CustomerEntities.Single(x => x.CustomerID == customerId);
                return Mapper.Map(entity);
            }
        }

        public void InsertCustomer(Customer customer)
        {
             using (var context = EntityObjectFactory.CreateContext())
             {
                 context.CustomerEntities.AddObject(Mapper.Map(customer));
             }
        }
    }
}